const storage = window.localStorage
const combination = {
    state: {
        templateList: [],
        globalSet: {
            labelPosition: 'right',
            labelWidth: 60,
            background: '#fff'
        },
        isDriver: false
    },
    mutations: {
        // ���沼������
        SET_TEMPLATE_LIST(state, list) {
            storage.setItem('templateList', JSON.stringify(list))
            state.templateList = list
        },
        // ɾ����������
        DEL_TEMPLATE_LIST(state, list) {
            storage.removeItem('templateList')
            storage.removeItem('globalSet')
            state.templateList = []
            state.globalSet = {}
        },
        // ����ȫ������-�����뷽ʽ
        SET_GLOBAL_SET_LABELlPOSITION(state, list) {
            state.globalSet.labelPosition = list
        },
        // ����ȫ������-��label���
        SET_GLOBAL_SET_LABELlWIDTH(state, list) {
            state.globalSet.labelWidth = list
        },
        // ����ȫ������-������ɫ����
        SET_GLOBAL_SET_BACKGROUND(state, list) {
            state.globalSet.background = list
        },
        // ����ȫ������
        SET_GLOBAL_SET(state, list) {
            storage.setItem('globalSet', JSON.stringify(list))
            state.globalSet = list
        },
        // �򿪲���ָ��
        SET_IS_DRIVER(state, isDriver) {
            storage.setItem('isDriver', JSON.stringify(isDriver))
            state.isDriver = isDriver
        }
    },
    actions: {
        // ���沼������
        set_template_list({ commit }, list) {
            commit('SET_TEMPLATE_LIST', list)
        },
        // ɾ����������
        del_template_list({ commit }, list) {
            commit('DEL_TEMPLATE_LIST')
        },
        // ����ȫ������-�����뷽ʽ
        set_global_set_labelPosition({ commit }, list) {
            commit('SET_GLOBAL_SET_LABELlPOSITION', list)
        },
        // ����ȫ������-��label���
        set_global_set_labelWidth({ commit }, list) {
            commit('SET_GLOBAL_SET_LABELlWIDTH', list)
        },
        // ����ȫ������-������ɫ����
        set_global_set_background({ commit }, list) {
            commit('SET_GLOBAL_SET_BACKGROUND', list)
        },
        // ����ȫ������
        set_global_set({ commit }, list) {
            commit('SET_GLOBAL_SET', list)
        },
        // ����ȫ������
        set_is_driver({ commit }, isDriver) {
            commit('SET_IS_DRIVER', isDriver)
        }
    }
}

export default combination
